<template>
  <div class="finally">
    <div class="tar">您当前排{{ score }}名</div>
    <div class="list-query" v-for="(item, index) in infoList" :key="item.id">
      <item :info="item" :index="index"></item>
    </div>
  </div>
</template>

<script>
import { ref, toRefs } from "@vue/reactivity";
import Item from "./item.vue";
import { onMounted } from "@vue/runtime-core";
import { getTarStudentScore, getTarTeacherScore } from "../../network/axios";
import { Notify } from "vant";
export default {
  components: {
    Item,
  },
  props: ["infoList", "count"],
  setup(props, context) {
    let score = ref(0);
    onMounted(async () => {
      const types = localStorage.getItem("type");

      const {
        data: {
          code,
          result: { sort },
        },
      } = types == 1 ? await getTarStudentScore() : await getTarTeacherScore();
      if (code === 200) {
        // 读取个人排名成功
        score.value = sort;
      } else {
        Notify({
          type: "danger",
          message: "获取个人排名失败",
        });
      }
    });
    return {
      score,
    };
  },
};
</script>

<style lang="scss" scoped>
.tar {
  font-size: 0.4rem;
  background: -webkit-linear-gradient(left, #4ea4fd, #25d0fd, #18ddfe, #00f0fd);
  margin: 0.25rem 0.2rem 0;
  border-radius: 0.2rem;
  line-height: 0.8rem;
  text-align: center;
  color: #fff;
}
</style>
